package cn.openread.demo.algorithm.p2;

/**
 * 用途:一切为了业务
 *
 * @author simon
 * @date 2019-12-23 16:59
 */
public class P2Main {

    public static void main(String[] args) throws InterruptedException {
        FooBar fooBar = new FooBar(2);


        Thread n1 = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    fooBar.foo(new Runnable() {
                        @Override
                        public void run() {
                            System.out.print("foo");
                        }
                    });
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });


        Thread n2 = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    fooBar.bar(new Runnable() {
                        @Override
                        public void run() {
                            System.out.print("bar");
                        }
                    });
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        n1.start();
        n2.start();
        Thread.currentThread().join();
    }
}
